Skip to content

Made the terminal resizable, move let and const to top of the script …#350

Merged
jbampton merged 7 commits intoNextCommunity:mainfrom
MaxFork:max-updates-terminal-resize
Mar 20, 2026
Merged

Made the terminal resizable, move let and const to top of the script …#350
jbampton merged 7 commits intoNextCommunity:mainfrom
MaxFork:max-updates-terminal-resize

Conversation

@BaseMax
Copy link
Member

@BaseMax BaseMax commented Mar 18, 2026

…file

@BaseMax BaseMax requested a review from jbampton as a code owner March 18, 2026 08:41
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the user interface by introducing resizable functionality to the system log terminal, providing a more flexible and user-friendly experience. Concurrently, it improves code structure and readability by centralizing variable declarations in the main JavaScript file.

Highlights

  • Resizable Terminal: The system log terminal is now resizable, allowing users to adjust its width and height using dedicated resize handles.
  • Code Refactoring: JavaScript let and const variable declarations in script.js were moved to the top of the file for better organization and adherence to best practices.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces resizability to the terminal window and refactors variable declarations by moving them to the top of the script. The implementation is a good start, but there are opportunities for improvement in terms of performance, maintainability, and user experience. My detailed comments provide specific suggestions for these areas.

Comment on lines +191 to +261
dragContainer.querySelectorAll('.resize-handle').forEach(handle => {
handle.addEventListener('mousedown', (e) => {
e.preventDefault();
e.stopPropagation();

isResizing = true;

resizeDirection = [...handle.classList]
.find(c => c.startsWith('resize-handle-') && c !== 'resize-handle')
?.replace('resize-handle-', '') || 'se';

const rect = dragContainer.getBoundingClientRect();
resizeStartX = e.clientX;
resizeStartY = e.clientY;
resizeStartWidth = rect.width;
resizeStartLeft = rect.left;
resizeStartTop = rect.top;
resizeStartOutputHeight = consoleOutput.offsetHeight;

dragContainer.style.bottom = 'auto';
dragContainer.style.right = 'auto';
dragContainer.style.left = `${rect.left}px`;
dragContainer.style.top = `${rect.top}px`;

dragContainer.classList.remove('transition-all', 'duration-300', 'ease-in-out');
document.body.style.userSelect = 'none';
document.body.style.cursor = handle.style.cursor;
});
});

document.addEventListener('mousemove', (e) => {
if (!isResizing) return;

const dx = e.clientX - resizeStartX;
const dy = e.clientY - resizeStartY;
const dir = resizeDirection;

// Horizontal
if (dir.includes('e')) {
dragContainer.style.width = `${Math.max(MIN_CONSOLE_WIDTH, resizeStartWidth + dx)}px`;
}
if (dir.includes('w')) {
const newW = resizeStartWidth - dx;
if (newW >= MIN_CONSOLE_WIDTH) {
dragContainer.style.width = `${newW}px`;
dragContainer.style.left = `${resizeStartLeft + dx}px`;
}
}

// Vertical — only the output area grows/shrinks, header stays fixed
if (dir.includes('s')) {
consoleOutput.style.height = `${Math.max(MIN_OUTPUT_HEIGHT, resizeStartOutputHeight + dy)}px`;
}
if (dir.includes('n')) {
const newH = resizeStartOutputHeight - dy;
if (newH >= MIN_OUTPUT_HEIGHT) {
consoleOutput.style.height = `${newH}px`;
dragContainer.style.top = `${resizeStartTop + dy}px`;
}
}
});

document.addEventListener('mouseup', () => {
if (!isResizing) return;
isResizing = false;
resizeDirection = '';
document.body.style.userSelect = '';
document.body.style.cursor = '';
// Restore CSS transition
dragContainer.classList.add('transition-all', 'duration-300', 'ease-in-out');
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This implementation for resizing has a few areas for improvement:

  • Performance: The mousemove and mouseup event listeners are attached to the document permanently. It's more efficient to add them on mousedown and remove them on mouseup.
  • User Experience: Resizing from the 'w' and 'n' directions feels jerky when the minimum size is reached. Clamping the values provides a smoother experience.
  • Maintainability: Getting the resize direction by parsing class names is fragile. Using a data-direction attribute is more robust.

Here is a refactored version that addresses these points. This change assumes you have updated the HTML for the resize handles to use data-direction attributes as suggested in my other comment.

const doResize = (e) => {
  const dx = e.clientX - resizeStartX;
  const dy = e.clientY - resizeStartY;

  // Horizontal
  if (resizeDirection.includes('e')) {
    dragContainer.style.width = `${Math.max(MIN_CONSOLE_WIDTH, resizeStartWidth + dx)}px`;
  }
  if (resizeDirection.includes('w')) {
    const newWidth = Math.max(MIN_CONSOLE_WIDTH, resizeStartWidth - dx);
    dragContainer.style.width = `${newWidth}px`;
    dragContainer.style.left = `${resizeStartLeft + (resizeStartWidth - newWidth)}px`;
  }

  // Vertical
  if (resizeDirection.includes('s')) {
    consoleOutput.style.height = `${Math.max(MIN_OUTPUT_HEIGHT, resizeStartOutputHeight + dy)}px`;
  }
  if (resizeDirection.includes('n')) {
    const newHeight = Math.max(MIN_OUTPUT_HEIGHT, resizeStartOutputHeight - dy);
    consoleOutput.style.height = `${newHeight}px`;
    dragContainer.style.top = `${resizeStartTop + (resizeStartOutputHeight - newHeight)}px`;
  }
};

const stopResize = () => {
  isResizing = false;
  document.body.style.userSelect = '';
  document.body.style.cursor = '';
  dragContainer.classList.add('transition-all', 'duration-300', 'ease-in-out');

  document.removeEventListener('mousemove', doResize);
  document.removeEventListener('mouseup', stopResize);
};

dragContainer.querySelectorAll('.resize-handle').forEach(handle => {
  handle.addEventListener('mousedown', (e) => {
    e.preventDefault();
    e.stopPropagation();

    isResizing = true;
    resizeDirection = e.currentTarget.dataset.direction || 'se';

    const rect = dragContainer.getBoundingClientRect();
    resizeStartX = e.clientX;
    resizeStartY = e.clientY;
    resizeStartWidth = rect.width;
    resizeStartLeft = rect.left;
    resizeStartTop = rect.top;
    resizeStartOutputHeight = consoleOutput.offsetHeight;

    dragContainer.style.bottom = 'auto';
    dragContainer.style.right = 'auto';
    dragContainer.style.left = `${rect.left}px`;
    dragContainer.style.top = `${rect.top}px`;

    dragContainer.classList.remove('transition-all', 'duration-300', 'ease-in-out');
    document.body.style.userSelect = 'none';
    document.body.style.cursor = window.getComputedStyle(e.currentTarget).cursor;

    document.addEventListener('mousemove', doResize);
    document.addEventListener('mouseup', stopResize);
  });
});

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong.
Your code acts differently; it only allow resizing to make it bigger from right side not the left side.

@jbampton jbampton added this to Next Mar 18, 2026
@github-project-automation github-project-automation bot moved this to In progress in Next Mar 18, 2026
@jbampton jbampton self-assigned this Mar 18, 2026
@BaseMax BaseMax added the enhancement New feature or request label Mar 18, 2026
@BaseMax BaseMax moved this from In progress to Review in progress in Next Mar 18, 2026
@BaseMax BaseMax added this to the Hackfest milestone Mar 18, 2026
@jbampton
Copy link
Member

pre-commit is failing

@deepsource-io
Copy link

deepsource-io bot commented Mar 19, 2026

DeepSource Code Review

We reviewed changes in 2daa16c...ec7d471 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

Important

Some issues found as part of this review are outside of the diff in this pull request and aren't shown in the inline review comments due to GitHub's API limitations. You can see those issues on the DeepSource dashboard.

PR Report Card

Overall Grade  

Focus Area: Hygiene
Security  

Reliability  

Complexity  

Hygiene  

Feedback

  • Leaky global scope causes collisions and duplicates
    • Functions, vars and listeners are defined at module/global scope, so names collide, redeclarations occur, and handlers get reattached; encapsulate state in a module/IIFE and export only deliberate globals so init runs once.
  • Missing init/teardown lifecycle lets resources accumulate
    • Setup happens ad hoc (listeners, audioCtx), with no deterministic init or cleanup, so handlers duplicate and initialization is delayed; centralize explicit init and destroy paths and make resource ownership clear.
  • Mutable, scattered state inflates branching and complexity
    • Reassignable globals and scattered checks force more branches and larger functions, causing high cyclomatic complexity and accidental redeclarations; adopt immutable bindings, a single source-of-truth state, and small pure helpers to cut branches.

Code Review Summary

Analyzer Status Updated (UTC) Details
JavaScript Mar 20, 2026 9:22a.m. Review ↗
Secrets Mar 20, 2026 9:22a.m. Review ↗


let audioCtx;

let unlockedEggs = JSON.parse(localStorage.getItem("unlockedEggs")) || [];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use `const` for variables never reassigned


The variable unlockedEggs is assigned once and never reassigned, so declaring it with let is misleading and allows accidental reassignments that can introduce bugs. Using const signals the variable's value is fixed after initialization, improving code clarity and safety.

Replace let with const for unlockedEggs to prevent unintended reassignment and clearly indicate its intended immutability.

let unlockedEggs = JSON.parse(localStorage.getItem("unlockedEggs")) || [];
let surpriseClickCount = 0;
let matrixActive = false;
let destructInterval;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uninitialized `let` declaration risks undefined usage


Declaring destructInterval with let without initializing it means it holds an undefined value until explicitly assigned. Accessing it before assignment can cause runtime errors or logic issues.

Initialize destructInterval during declaration with an appropriate default value to ensure defined behavior and prevent undefined usage.

});
});

document.addEventListener("mousemove", (e) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function with high cyclomatic complexity is hard to understand


The event listener function for the 'mousemove' event on document likely contains multiple branches or conditions increasing cyclomatic complexity. This complexity can introduce bugs and make the logic challenging to follow or extend.

Refactor the function by splitting complex logic into smaller functions, and reduce nested conditional statements to simplify the flow.

Comment on lines +241 to +260
if (dir.includes("s")) {
consoleOutput.style.height = `${Math.max(MIN_OUTPUT_HEIGHT, resizeStartOutputHeight + dy)}px`;
}
if (dir.includes("n")) {
const newH = resizeStartOutputHeight - dy;
if (newH >= MIN_OUTPUT_HEIGHT) {
consoleOutput.style.height = `${newH}px`;
dragContainer.style.top = `${resizeStartTop + dy}px`;
}
}
});

document.addEventListener("mouseup", () => {
if (!isResizing) return;
isResizing = false;
resizeDirection = "";
document.body.style.userSelect = "";
document.body.style.cursor = "";
dragContainer.classList.add("transition-all", "duration-300", "ease-in-out");
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate `document` event listeners for `mousemove` and `mouseup`


The code adds mousemove and mouseup event listeners to the document object. However, listeners for these same events on document already exist for the drag functionality. Attaching multiple listeners for the same event on a global object is inefficient and makes the code harder to maintain and debug.

Consolidate the logic into a single mousemove and a single mouseup listener on the document. Use state variables like isDragging and isResizing within these listeners to delegate to the correct logic.


let isSurging = false;

let audioCtx;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uninitialized `audioCtx` declaration delays initialization


The variable audioCtx is declared without being initialized, which can make the code less clear and increase the risk of using it before assignment. Uninitialized variables can cause unexpected runtime errors or logic bugs if accessed prematurely.
Initialize variables like audioCtx at the time of declaration to improve code clarity and reduce the chance of accidental misuse.

Copy link
Member

@jbampton jbampton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done thanks !! 🥇

@github-project-automation github-project-automation bot moved this from Review in progress to Reviewer approved in Next Mar 20, 2026
@jbampton jbampton merged commit 5cddac8 into NextCommunity:main Mar 20, 2026
6 of 7 checks passed
@github-project-automation github-project-automation bot moved this from Reviewer approved to Done in Next Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants